Add a title property to GtkStatusIcon
authorMatthias Clasen <mclasen@redhat.com>
Sat, 20 Jun 2009 17:53:32 +0000 (13:53 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 20 Jun 2009 17:53:32 +0000 (13:53 -0400)
This can be used to give ATs a string to display for tray icons.
See bug 585802.

docs/reference/gtk/gtk-sections.txt
gtk/gtk.symbols
gtk/gtkstatusicon.c
gtk/gtkstatusicon.h

index 992f03d5fdf6d513b7271e888a6e0af662c22e47..3d93755cbac1352833b3dcd858614e568056d996 100644 (file)
@@ -3595,6 +3595,8 @@ gtk_status_icon_set_tooltip_markup
 gtk_status_icon_get_tooltip_markup
 gtk_status_icon_set_has_tooltip
 gtk_status_icon_get_has_tooltip
+gtk_status_icon_set_title
+gtk_status_icon_get_title
 gtk_status_icon_set_visible
 gtk_status_icon_get_visible
 gtk_status_icon_set_blinking
index ac4fa2cf72e9804390ef09b52a135c7b6d8bf85d..3fdbb67703bf51016914e7b5f7876c10eb906a4d 100644 (file)
@@ -1213,6 +1213,8 @@ gtk_status_icon_is_embedded
 gtk_status_icon_position_menu
 gtk_status_icon_get_geometry
 gtk_status_icon_get_x11_window_id
+gtk_status_icon_get_title
+gtk_status_icon_set_title
 #endif
 #endif
 
index 3e89f5362cbc809aed533c68e4d1735f27e463c6..f7fa00901063b60b36d509e74ce8f8c265122943 100644 (file)
@@ -82,7 +82,8 @@ enum
   PROP_BLINKING,
   PROP_HAS_TOOLTIP,
   PROP_TOOLTIP_TEXT,
-  PROP_TOOLTIP_MARKUP
+  PROP_TOOLTIP_MARKUP,
+  PROP_TITLE
 };
 
 enum 
@@ -116,12 +117,14 @@ struct _GtkStatusIconPrivate
   gint         last_click_x, last_click_y;
   GtkOrientation orientation;
   gchar         *tooltip_text;
+  gchar         *title;
 #endif
        
 #ifdef GDK_WINDOWING_QUARTZ
   GtkWidget     *dummy_widget;
   GtkQuartzStatusIcon *status_item;
   gchar         *tooltip_text;
+  gchar         *title;
 #endif
 
   gint          size;
@@ -402,6 +405,23 @@ gtk_status_icon_class_init (GtkStatusIconClass *class)
                                                        GTK_PARAM_READWRITE));
 
 
+  /**
+   * GtkStatusIcon:title:
+   *
+   * The title of this tray icon. This should be a short, human-readable,
+   * localized string describing the tray icon. It may be used by tools
+   * like screen readers to render the tray icon.
+   *
+   * Since: 2.18
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TITLE,
+                                   g_param_spec_string ("title",
+                                                        P_("Title"),
+                                                        P_("The title of this tray icon"),
+                                                        NULL,
+                                                        GTK_PARAM_READWRITE));
+
   /**
    * GtkStatusIcon::activate:
    * @status_icon: the object which received the signal
@@ -1029,6 +1049,9 @@ gtk_status_icon_set_property (GObject      *object,
     case PROP_TOOLTIP_MARKUP:
       gtk_status_icon_set_tooltip_markup (status_icon, g_value_get_string (value));
       break;
+    case PROP_TITLE:
+      gtk_status_icon_set_title (status_icon, g_value_get_string (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1111,6 +1134,9 @@ gtk_status_icon_get_property (GObject    *object,
     case PROP_TOOLTIP_MARKUP:
       g_value_set_string (value, gtk_status_icon_get_tooltip_markup (status_icon));
       break;
+    case PROP_TITLE:
+      g_value_set_string (value, gtk_status_icon_get_title (status_icon));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -2871,5 +2897,73 @@ gtk_status_icon_get_x11_window_id (GtkStatusIcon *status_icon)
 #endif
 }
 
+/**
+ * gtk_status_icon_set_title:
+ * @status_icon: a #GtkStatusIcon
+ * @title: the title 
+ *
+ * Sets the title of this tray icon.
+ * This should be a short, human-readable, localized string 
+ * describing the tray icon. It may be used by tools like screen
+ * readers to render the tray icon.
+ *
+ * Since: 2.18
+ */
+void
+gtk_status_icon_set_title (GtkStatusIcon *status_icon,
+                           const gchar   *title)
+{
+  GtkStatusIconPrivate *priv;
+
+  g_return_if_fail (GTK_IS_STATUS_ICON (status_icon));
+
+  priv = status_icon->priv;
+
+#ifdef GDK_WINDOWING_X11
+  gtk_window_set_title (GTK_WINDOW (priv->tray_icon), title);
+#endif
+#ifdef GDK_WINDOWING_QUARTZ
+  g_free (priv->title);
+  priv->title = g_strdup (title);
+#endif
+#ifdef GDK_WINDOWING_WIN32
+  g_free (priv->title);
+  priv->title = g_strdup (title);
+#endif
+
+  g_object_notify (G_OBJECT (status_icon), "title");
+}
+
+/**
+ * gtk_status_icon_get_title:
+ * @status_icon: a #GtkStatusIcon
+ *
+ * Gets the title of this tray icon. See gtk_status_icon_set_title().
+ *
+ * Returns: the title of the status icon
+ *
+ * Since: 2.18
+ */
+G_CONST_RETURN gchar *
+gtk_status_icon_get_title (GtkStatusIcon *status_icon)
+{
+  GtkStatusIconPrivate *priv;
+
+  g_return_if_fail (GTK_IS_STATUS_ICON (status_icon));
+
+  priv = status_icon->priv;
+
+#ifdef GDK_WINDOWING_X11
+  return gtk_window_get_title (GTK_WINDOW (priv->tray_icon));
+#endif
+#ifdef GDK_WINDOWING_QUARTZ
+  return priv->title;
+#endif
+#ifdef GDK_WINDOWING_WIN32
+  return priv->title;
+#endif
+}
+
+
 #define __GTK_STATUS_ICON_C__
 #include "gtkaliasdef.c"
index 19db689a303b7b7aac9db4c52a83c61888f12bf1..e850c64c798e1f6843372db3069d56008be5c193 100755 (executable)
@@ -120,6 +120,9 @@ void                  gtk_status_icon_set_tooltip_text   (GtkStatusIcon      *st
                                                           const gchar        *text);
 void                  gtk_status_icon_set_tooltip_markup (GtkStatusIcon      *status_icon,
                                                           const gchar        *markup);
+void                  gtk_status_icon_set_title          (GtkStatusIcon      *status_icon,
+                                                          const gchar        *title);
+G_CONST_RETURN gchar *gtk_status_icon_get_title          (GtkStatusIcon      *status_icon);
 void                  gtk_status_icon_set_visible        (GtkStatusIcon      *status_icon,
                                                          gboolean            visible);
 gboolean              gtk_status_icon_get_visible        (GtkStatusIcon      *status_icon);